<?php
namespace Dao6\Tests\SDK;
use Dao6\Cache\MemcacheCache;
use Dao6\SDK50R;


class SDKTest extends \PHPUnit_Framework_TestCase
{
    public function testConvert()
    {
        $ak = '57ac3816d9cb467d121dd48f'; //替换成你自己的AppKey
        $sdk = SDK50R::getInstance();
        $sdk->setAppKey($ak)->enableHttps();
        $res = $sdk->convert('http://www.baidu.com/s?word=hello');
        $this->assertContains('"error":null', $res->raw);
    }

    public function testHTTPS(){
        $ak = '57ac3816d9cb467d121dd48f'; //替换成你自己的AppKey
        $sdk = new SDK50R($ak, true);
        $res = $sdk->convert('http://www.baidu.com/s?word=hello');
        $this->assertContains('"error":null', $res->raw);
    }

    public function testMemcache(){
        $ak = '57ac3816d9cb467d121dd48f'; //替换成你自己的AppKey
        $sdk = new SDK50R($ak, false, false);
        $sdk->enableCache(new MemcacheCache());
        $res = $sdk->convert('http://www.baidu.com/s?word=hello%23world');
        $this->assertContains('"error":null', $res->raw);
    }

    public function testDisableCache(){
        $ak = '57ac3816d9cb467d121dd48f'; //替换成你自己的AppKey
        $sdk = new SDK50R($ak, false, false);
        $res = $sdk->convert('http://www.baidu.com/s?word=hello%23world');
        $this->assertContains('"error":null', $res->raw);
    }
}